﻿// Decompiled with JetBrains decompiler
// Type: LayersParser.Objects.Motion
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;


namespace LayersParser.Objects;

public class Motion : Common
{
  private Layers uiLayer;
  private Layers simulationLayer;
  private Layers downloadLayer;
  private int motionType;
  private List<string> parameters;
  private List<IfCondition> conditions;

  public Motion(XElement layersNode, int motionIndex)
  {
    this.motionType = motionIndex;
    bool flag = false;
    if (layersNode.Element((XName) nameof (UILayer)) != null)
      this.uiLayer = new Layers(layersNode.Element((XName) nameof (UILayer)));
    if (layersNode.Element((XName) nameof (SimulationLayer)) != null)
      this.simulationLayer = new Layers(layersNode.Element((XName) nameof (SimulationLayer)));
    if (layersNode.Element((XName) nameof (Motion)) != null)
    {
      foreach (XElement xelement in layersNode.Elements((XName) nameof (Motion)).ToList<XElement>())
      {
        if ((string) xelement.Attribute((XName) "Type") == motionIndex.ToString())
        {
          this.downloadLayer = new Layers(xelement.Element((XName) nameof (DownloadLayer)));
          flag = true;
        }
      }
    }
    if (flag)
      return;
    this.downloadLayer = new Layers(new XElement((XName) nameof (DownloadLayer)));
    layersNode.Add((object) new XElement((XName) nameof (Motion), new object[2]
    {
      (object) new XAttribute((XName) "Type", (object) motionIndex),
      (object) this.downloadLayer.Node
    }));
  }

  public List<IfCondition> Conditions
  {
    get => this.conditions;
    set => this.conditions = value;
  }

  public List<string> Params
  {
    get => this.parameters;
    set
    {
      this.parameters = value;
      this.uiLayer.Params = this.parameters;
      this.downloadLayer.Params = this.parameters;
      this.simulationLayer.Params = this.parameters;
    }
  }

  public int MotionType
  {
    get => this.motionType;
    set => this.motionType = value;
  }

  public Layers DownloadLayer
  {
    get => this.downloadLayer;
    set => this.downloadLayer = value;
  }

  public Layers SimulationLayer
  {
    get => this.simulationLayer;
    set => this.simulationLayer = value;
  }

  public Layers UILayer
  {
    get => this.uiLayer;
    set => this.uiLayer = value;
  }
}
